<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<!-- Casting SPELs in Lisp - Emacs Lisp Edition, a Comic Book
     Written by Conrad Barski, M.D., http://lisperati.com
     Edited by James A. Webb, http://uberkode.com -->

<head>

  <title>Casting SPELs in Lisp (8)</title>
  <meta http-equiv="content-type" content="text/html;charset=utf-8" />
  <meta http-equiv="Content-Style-Type" content="text/css" />
  <meta name="author" content="James A. Webb" />
  <meta name="date" content="2007-09-16T00:00:00+00:00" />
  <meta name="keywords" content="Emacs, Lisp" />

</head>

<body>

<center>

<table cellspacing="10" width="500">
  <tr>
    <td bgcolor="#AAFFAA" height="50" align="center">
        <b>Defining the Data for our Game World</b>
    </td>
  </tr>
  <tr>
    <td>
      In order to learn some more about forms, let's create 
      some forms that create the data for our game world. First 
      of all, our game is going to have some objects in it that 
      the player can pick up and use - let's define those objects:
    </td>
  </tr>
  <tr>
    <td>
<pre style="font-weight: bolder; color: darkblue">
  (setq objects '(whiskey-bottle bucket frog chain))
</pre>
    </td>
  </tr>
  <tr>
    <td>
      Ok, now let's dissect this line an see what it means: 
      Since a Lisp interpreter always starts reading things 
      in <i>Code</i> mode and expects a form, the first symbol, 
      <tt>setq</tt>, must be a command. In this case, the command 
      sets a variable to a value: The variable is <tt>objects</tt> 
      and the value we are setting it to is a list of four objects. 
      Now, since the list is data (i.e., we don't want the compiler 
      to try and call a function called <tt>whiskey-bottle</tt>), 
      we need to "flip" the compiler into <i>Data</i> mode when reading 
      the list. The single quote in front of the list is the 
      command that tells the compiler to flip:
    </td>
  </tr>
  <tr>
    <td align="center">
      <img src="../images/game-objects.jpg"
        width="500" 
        height="215" 
        alt="Lisp code defining the game objects" />
    </td>
  </tr>
  <tr>
    <td align="center">
      &lt;&lt; <a href="casting-spels-emacs-1.html">begin</a>
      &lt; <a href="casting-spels-emacs-7.html">previous</a> - 
      <a href="casting-spels-emacs-9.html">next</a> &gt;
      <a href="casting-spels-emacs-35.html" >end</a> &gt;&gt;
    </td>
  </tr>
</table>

</center>

</body>

</html>